import junit.framework.TestCase;
import org.junit.Test;

public class AllCreaturesTest extends TestCase {
    @Test
    public void testAdd() throws Exception {
        Position position = new Position(2, 2, 10, 10);
        Obstacle obstacle = new Obstacle(position);
        Victim victim = new Victim(position);
        AllCreatures allCreatures = new AllCreatures(0, 0, 0, 10, 10);
        allCreatures.add(obstacle);
        assertEquals(false, allCreatures.add(victim));
    }

    @Test
    public void testFindNearestVictim() throws Exception {
        Position positionPredator = new Position(3, 4, 10, 10);
        Position positionVictim = new Position(2, 2, 10, 10);
        Predator predator = new Predator(positionPredator);
        Victim victim = new Victim(positionVictim);
        AllCreatures allCreatures = new AllCreatures(0, 0, 0, 10, 10);
        allCreatures.add(predator);
        allCreatures.add(victim);
        MotionInformation motionInformation=new MotionInformation(Direction.UP_LEFT,2);
        assertEquals(motionInformation, allCreatures.findNearestVictim(predator.getPosition(), 3));
    }

    @Test
    public void testisVictimOnPosition() throws Exception {
        Position positionVictim = new Position(2, 2, 10, 10);
        Position position = new Position(2, 2, 10, 10);

        Victim victim = new Victim(positionVictim);
        AllCreatures allCreatures = new AllCreatures(0, 0, 0, 10, 10);
        allCreatures.add(victim);
        assertEquals(true, allCreatures.isVictimOnPosition(position));
    }

    @Test
    public void testisObstacleOnPosition() throws Exception {
        Position positionObstacle = new Position(2, 2, 10, 10);
        Position position = new Position(2, 2, 10, 10);

        Obstacle obstacle = new Obstacle(positionObstacle);
        AllCreatures allCreatures = new AllCreatures(0, 0, 0, 10, 10);
        allCreatures.add(obstacle);
        assertEquals(true, allCreatures.isObstacleOnPosition(position));
    }

    @Test
    public void testCreate() throws Exception {
        Position positionVictim = new Position(2, 2, 10, 10);
        Position position = new Position(2, 2, 10, 10);

        Victim victim = new Victim(positionVictim);
        Obstacle obstacle = new Obstacle(position);
        AllCreatures allCreatures = new AllCreatures(0, 0, 0, 10, 10);
        allCreatures.add(obstacle);
        assertEquals(false, allCreatures.add(victim));
    }
}
